package com.vpen.iot.manager;

import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONUtil;
import lombok.Data;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author Vpen
 * @date 2024/1/24 12:30
 */
@Data
@Accessors(chain = true)
public class Points implements Serializable {
    private static final long serialVersionUID = 5342403073239175616L;
    private Integer type;
    private String points;

    private String a;

    public static void main(String[] args) {
        List<Points> list = new ArrayList<>();
        list.add(new Points().setType(1).setPoints("第1个面"));
        list.add(new Points().setType(2).setPoints("第2个面"));
        list.add(new Points().setType(3).setPoints("第3个面"));
        Points points = new Points();
        points.setA(JSONUtil.toJsonStr(list));
        String a ="[{\"type\":1,\"points\":\"第1个面\"},{\"type\":2,\"points\":\"第2个面\"},{\"type\":3,\"points\":\"第3个面\"}]";
        JSONArray jsonArray = JSONUtil.parseArray(a);
        List<Points> list1 = jsonArray.stream().map(e -> JSONUtil.toBean(e.toString(), Points.class)).collect(Collectors.toList());
        System.out.println(list1);
    }
}
